<?php

$response = '';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://xoap.weather.com/weather/local/SRXX0021?cc=*&dayf=2&link=xoap&prod=xoap&par=1197447447&key=43e103dae96b02ae");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 0);

$xml_str=curl_exec($ch);

if(!$xml_str) exit("Problem sa file_get_contects");

//close CURL cause we dont need it anymore
curl_close($ch);

// Parses XML
$xml = new SimplexmlElement($xml_str);
if(!$xml) exit("Problem sa SimpleXMLElement objektom");
//print_r($xml);
//exit;
// Name
$response.= "<h1 class='borBot'></h1>";
$response.= "<table class='borBot' style='margin:10px 0 10px; text-align:center' cellspacing='0' cellpading='0' width='100%'>
                                <tbody>
                                        <tr>";
//Set date
$date = substr($xml->dayf->lsup, 0, 8);
$date = explode("/", $date);
$day = 0;
foreach($xml->dayf->day as $item) {
        if($item->hi != 'N/A'){
                $date_out = @date("d-m-Y", mktime(0, 0, 0, $date[0], $date[1]+$day, "20".$date[2]));
                $day++;
                $response.= "<td>";
                $max = round((5/9)*($item->low-32));
                $response .= "<div>min temp: ".$max."&deg</div>";
                $min = round((5/9)*($item->hi-32));
                $response .= "<div>max temp: ".$min."&deg</div>";
$response .= "<br/>";
$first = true;
                foreach($item->part as $new) {

                        $response.= '<div>';
                                // Image size options 25, 31, 45, 52, 61, 72, 78, 93
                                $response.= '<img src="http://s.imwx.com/v.20100415.153311/img/wxicon/93/'.$new->icon.'.png"/><br/>';
                        $response.= '</div>';
                        break;
    $response .= "<br/>";
    $first = false;
                }
                $response .= "</td>";
        }
}
$response.= "</tr>
                                </tbody>
                                        </table>";

echo $response;